﻿using IR.Controller.ModelControllers;
using IR.WPF.ViewModels.LandingViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using IR.WPF.Interfaces;

namespace IR.WPF.UI.ViewModels
{
    public class VMViewPage : ViewModelBase
    {
        private VMVersionHeader _versionHeader;
        private VMVersionDetail _versionDetail;
        private VMIdeaHeader _ideaHeader;
        private VMIdeaDetail _ideaDetail;
        private VMUserHeader _userHeader;
        private VMUserDetail _userDetail;
        private VMOptionPane _optionPane;

        public VMViewPage()
        {
            WindowTitle = "IdeaRepository";
        }

        public override void DoCleanup()
        {
            NotifyPropertyChanged("ViewPageClosed", this);
        }

        #region **View Models**
        public VMVersionHeader VersionHeader
        {
            get
            {
                if (_versionHeader == null)
                    _versionHeader = new VMVersionHeader();

                return _versionHeader;
            }
        }

        public VMVersionDetail VersionDetail
        {
            get
            {
                if (_versionDetail == null)
                    _versionDetail = new VMVersionDetail(BoundWindow);

                _versionDetail.BoundWindow = BoundWindow;

                return _versionDetail;
            }
        }

        public VMUserHeader UserHeader
        {
            get
            {
                if (_userHeader == null)
                    _userHeader = new VMUserHeader();

                return _userHeader;
            }
        }

        public VMUserDetail UserDetail
        {
            get
            {
                if (_userDetail == null)
                    _userDetail = new VMUserDetail(BoundWindow);

                _userDetail.BoundWindow = BoundWindow;

                return _userDetail;
            }
        }

        public VMIdeaHeader IdeaHeader
        {
            get
            {
                if (_ideaHeader == null)
                    _ideaHeader = new VMIdeaHeader();

                return _ideaHeader;
            }
        }

        public VMIdeaDetail IdeaDetail
        {
            get
            {
                if (_ideaDetail == null)
                    _ideaDetail = new VMIdeaDetail(BoundWindow);

                _ideaDetail.BoundWindow = BoundWindow;

                return _ideaDetail;
            }
        }

        public VMOptionPane OptionPane
        {
            get
            {
                if (_optionPane == null)
                {
                    // Replace 0's with currently selected controller
                    if (_versionHeader != null)
                    {
                        _optionPane = new VMOptionPane(_versionHeader, 0);
                    }
                    else if (_ideaHeader != null)
                    {
                        _optionPane = new VMOptionPane(_ideaHeader, 0);
                    }
                    else if (_userHeader != null)
                    {
                        _optionPane = new VMOptionPane(_userHeader, 0);
                    }
                }

                return _optionPane;
            }
        }
        #endregion
    }
}
